home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 342_01.zip / DIOFNC10.C < prev    next >
Text File  |  1993-04-03  |  2KB  |  57 lines

  1. /*-
  2.  *  ----------------------------------------------------------------------
  3.  *  File        :   DIOFNC10.C
  4.  *  Creator     :   Blake Miller
  5.  *  Version     :   01.01.00            February 1991
  6.  *  Language    :   Microsoft Quick C   Version 2.0
  7.  *  Purpose     :   Intel 8255 Compatible Digital IO Functions
  8.  *                  80X86 IN Instruction Function
  9.  *  ----------------------------------------------------------------------
  10.  *  WARNING: Inline Assembly Language Here!
  11.  *  ----------------------------------------------------------------------
  12.  *  Revision History:
  13.  *  022891 BVM  :   Change int to short.
  14.  *  070490 BVM  :   Creation
  15.  *  ----------------------------------------------------------------------
  16.  */
  17.  
  18. #define     DIOFNC10_C_DEFINED  1
  19. #undef      DIOFNC10_C_DEFINED
  20.  
  21. void dio_bget (short d_port, unsigned char *d_byte);
  22.  
  23. /*- DIO : Byte Get ---------------------------**
  24.  *  Read a byte from one of the 80X86 ports.
  25.  *  Duplicates the library function inp()
  26.  */
  27. void dio_bget (short d_port, unsigned char *d_byte)
  28.     {
  29.     unsigned char   t_byte = 0; /* temporary byte   */
  30.  
  31.     /*  set port address
  32.      *  get data into AL
  33.      *  store data into temporary variable
  34.      *  Note: Use temporary variable because ASM has no idea
  35.      *  what a pointer to an unsigned char is!
  36.      */
  37.     _asm    {
  38.         PUSH    AX
  39.         PUSH    DX
  40.  
  41.         MOV     DX, d_port
  42.         IN      AL, DX          ; get byte into AL
  43.         MOV     t_byte, AL      ; transfer data to C
  44.  
  45.         POP     DX
  46.         POP     AX
  47.         }
  48.  
  49.     *d_byte = t_byte;   /* transfer data to caller  */
  50.     }
  51.  
  52. /*-
  53.  *  ----------------------------------------------------------------------
  54.  *  END DIOFNC10.C Source File
  55.  *  ----------------------------------------------------------------------
  56.  */
  57.